// maximum flow
//achilles
#include <stdio.h>
#include <string.h>

#define maxn 	1001
#define inf 	0x7fffffff

int g[maxn][maxn], f[maxn][maxn], v[maxn], pre[maxn], n, s, t;

int min(int x, int y) { return x < y ? x : y; }

void update()
{
    int p,q;
    int minval=v[q=t];
    while ( q!=s )
    {
        p=pre[q];
        if (p>=n) p-=n, f[q][p]-=minval;
        else f[p][q]+=minval;
        q=p;
    }
}

int max_flow()
{
    int queue[maxn], p, q, k, i;
    while (true)
    {
        memset(pre, 0xff, sizeof(pre[0])*n);
        pre[s] = s;
        v[s] = inf;
        queue[p=q=0]=s;
        while (p<=q)
        {
            k=queue[p++];
            for (i=0;i<n;i++) if (pre[i]<0) 
            {
                if (g[k][i] > f[k][i])
                	v[i]=min(g[k][i]-f[k][i], v[k]), pre[i]=k, queue[++q]=i;
            	if (f[i][k] > 0)
            		v[i]=min(f[i][k], v[k]), pre[i]=k+n, queue[++q]=i;
            }
            if (pre[t]>=0) break;
        }
        if (pre[t]<0) break;
        update();
    }
    for (k=i=0;i<n;i++) k+=f[s][i];
    return k;
}

int main()
{
    while (scanf("%d%d%d",&n,&s,&t)!=EOF)
    {
    	int i,j,c;
    	for (i=0;i<n;i++) 
    	{
     		memset(g[i],0,sizeof(g[i][0])*n);
       		memset(f[i],0,sizeof(f[i][0])*n);
   		}
    	while (scanf("%d%d%d",&i,&j,&c)!=EOF) 
     	{
     	    if (i<0 && j<0 && c<0) break;
    	    g[i][j]=c;
      	}
	    printf("Maxflow is : %d\n", max_flow());
    }
    return 0;
}

